package com.xunji.standard.util;


import com.xunji.standard.common.TokenUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: orange-wisdom
 * @author: 吃素的沙漠狼
 * @create: 2025-06-28 16:03
 **/
@Slf4j
public class RequestContextUtil {
    public static String getUser(HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        if (StringUtils.isEmpty(token)) {
            log.info("请求接口未获取到token信息，用户未登录！");
            return null;
        }
        return TokenUtils.getUserId(token);
    }
}
